/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ve.com.cantv.worktables.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Ghust
 */
@Entity
@Table(name = "rolmodule")
@NamedQueries({@NamedQuery(name = "Rolmodule.findAll", query = "SELECT r FROM Rolmodule r"), @NamedQuery(name = "Rolmodule.findByIdrol", query = "SELECT r FROM Rolmodule r WHERE r.rolmodulePK.idrol = :idrol"), @NamedQuery(name = "Rolmodule.findByIdmodule", query = "SELECT r FROM Rolmodule r WHERE r.rolmodulePK.idmodule = :idmodule"), @NamedQuery(name = "Rolmodule.findByDatechange", query = "SELECT r FROM Rolmodule r WHERE r.datechange = :datechange")})
public class Rolmodule implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected RolmodulePK rolmodulePK;
    @Column(name = "datechange")
    @Temporal(TemporalType.DATE)
    private Date datechange;
    @JoinColumn(name = "idmodule", referencedColumnName = "idmodule", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Module module;
    @JoinColumn(name = "idrol", referencedColumnName = "idrol", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Rol rol;
    @JoinColumn(name = "iduser", referencedColumnName = "iduser")
    @ManyToOne
    private UUser iduser;

    public Rolmodule() {
    }

    public Rolmodule(RolmodulePK rolmodulePK) {
        this.rolmodulePK = rolmodulePK;
    }

    public Rolmodule(int idrol, int idmodule) {
        this.rolmodulePK = new RolmodulePK(idrol, idmodule);
    }

    public RolmodulePK getRolmodulePK() {
        return rolmodulePK;
    }

    public void setRolmodulePK(RolmodulePK rolmodulePK) {
        this.rolmodulePK = rolmodulePK;
    }

    public Date getDatechange() {
        return datechange;
    }

    public void setDatechange(Date datechange) {
        this.datechange = datechange;
    }

    public Module getModule() {
        return module;
    }

    public void setModule(Module module) {
        this.module = module;
    }

    public Rol getRol() {
        return rol;
    }

    public void setRol(Rol rol) {
        this.rol = rol;
    }

    public UUser getIduser() {
        return iduser;
    }

    public void setIduser(UUser iduser) {
        this.iduser = iduser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rolmodulePK != null ? rolmodulePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Rolmodule)) {
            return false;
        }
        Rolmodule other = (Rolmodule) object;
        if ((this.rolmodulePK == null && other.rolmodulePK != null) || (this.rolmodulePK != null && !this.rolmodulePK.equals(other.rolmodulePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ve.com.cantv.worktables.ejb.entity.Rolmodule[rolmodulePK=" + rolmodulePK + "]";
    }

}
